package edu.gatech.cs2340.teamrocket.model.storage;

import java.util.Random;
import edu.gatech.cs2340.teamrocket.model.item.*;

/**
 * This class creates ShopInventories for the starting location and for
 * other towns and cities.
 *
 * @author Joe Tacheron
 */
public class ShopInventoryFactory {

    private static final int STARTING_MONEY         = 3000;
    private static final int STARTING_POKEBALLS     = 100;
    private static final int STARTING_POTION        = 20;
    private static final int STARTING_ETHER         = 500;
    private static final int STARTING_FULLHEAL      = 10;
    private static final int STARTING_TAUROS        = 3;

    private static final int MIN_RANDOM_MONEY       = 20;
    private static final int MIN_RANDOM_POKEBALLS   = 10;
    private static final int MIN_RANDOM_POTION      = 5;
    private static final int MIN_RANDOM_ETHER       = 100;
    private static final int MIN_RANDOM_FULLHEAL    = 2;
    private static final int MIN_RANDOM_TAUROS      = 0;

    private static final int MAX_RANDOM_MONEY       = 200;
    private static final int MAX_RANDOM_POKEBALLS   = 20;
    private static final int MAX_RANDOM_POTION      = 10;
    private static final int MAX_RANDOM_ETHER       = 200;
    private static final int MAX_RANDOM_FULLHEAL    = 4;
    private static final int MAX_RANDOM_TAUROS      = 2;

    private static final Random RANDOM = new Random();

    /**
     *
     * @return a ShopInventory used at the beginning of the game.
     */
    public static ShopInventory getStartingShopInventory(){
        ShopInventory shopInv = new ShopInventory(STARTING_MONEY);
        shopInv.addItem(Item.PokeBall,  STARTING_POKEBALLS);
        shopInv.addItem(Item.Potion,    STARTING_POTION);
        shopInv.addItem(Item.Ether,     STARTING_ETHER);
        shopInv.addItem(Item.FullHeal,  STARTING_FULLHEAL);
        shopInv.addItem(Item.Tauros,    STARTING_TAUROS);
        return shopInv;
    }

    /**
     *
     * @return a ShopInventory with random contents
     */
    public static ShopInventory getRandomShopInventory(){
        ShopInventory retval = new ShopInventory(random(MIN_RANDOM_MONEY, MAX_RANDOM_MONEY));
        retval.addItem(Item.PokeBall,   random(MIN_RANDOM_POKEBALLS, MAX_RANDOM_POKEBALLS));
        retval.addItem(Item.Potion,     random(MIN_RANDOM_POTION, MAX_RANDOM_POTION));
        retval.addItem(Item.Ether,      random(MIN_RANDOM_ETHER, MAX_RANDOM_ETHER));
        retval.addItem(Item.FullHeal,   random(MIN_RANDOM_FULLHEAL, MAX_RANDOM_FULLHEAL));
        retval.addItem(Item.Tauros,     random(MIN_RANDOM_TAUROS, MAX_RANDOM_TAUROS));
        return retval;
    }

    private static int random(int min, int max){
        return min + RANDOM.nextInt(max - min);
    }
}